#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 2e5 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n;
int a[110];
void solve()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	int ans = 0, ans2 = 0;
	bool is_odd = false;//奇数开头
	if (a[1] % 2 == 0) ans++;
	for (int i = 2; i <= n; i++)
	{
		if (!is_odd)
		{
			if (a[i] % 2 == 0)
			{
				is_odd = true;
				continue;
			}
			else
			{
				ans++;
				continue;
			}
		}

		if (is_odd)
		{
			if (a[i] & 1)
			{
				is_odd = false;
				continue;
			}
			else
			{
				ans++;
				continue;
			}
		}
	}



	bool ok = false;
	if (a[1] % 2 == 0)
	{
		ok = true;
		is_odd = false;//奇数
		for (int i = 1; i <= n; i++)
		{
			if (!is_odd)
			{
				if (a[i] % 2 == 0)
				{
					is_odd = true;
					continue;
				}
				else
				{
					ans++;
					continue;
				}
			}
			if (is_odd)
			{
				if (a[i] & 1)
				{
					is_odd = false;
					continue;
				}
				else
				{
					ans2++;
					continue;
				}
			}
		}

	}
	if (ok) cout << min(ans, ans2) << '\n';
	else cout << ans << '\n';

}

int main()
{
	close();
	int T; cin >> T;
	while (T--) solve();
	return 0;
}
//奇x奇==奇 偶x偶==偶 奇x偶==奇